import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';

interface Data<T> {
  data: T[];
  pageCount: number;
  pageNum: number;
  pageSize: number;
  totalRecord: number;
}
interface Product {
  nid: string;
  pubTime: string;
  title: string;
}
@Component({
  selector: 'app-zero',
  templateUrl: './zero.component.html',
  styleUrls: ['./zero.component.css'],
})
export class ZeroComponent {
  postUrl: string = 'https://www.codeboy.com/mfresh/data/news_select.php';
  public productList: any[] = [];
  private pageNum = 7;
  constructor(private http: HttpClient) {}
  loadMore(): void {
    const formData = new FormData();
    formData.set('pageNum', `${this.pageNum}`);
    this.http.post(this.postUrl, formData).subscribe((res: any) => {
      this.productList.push(...res.data);
      this.pageNum -= 1;
    });
  }
  deleteClick(index: number) {
    this.productList.splice(index, 1);
  }
}
